#-*-coding:utf-8-*-
import sys
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *

class Rename(QWidget):
    newName_Signal=Signal(str)

    def __init__(self,originName):
        super(Rename,self).__init__()

        self.setWindowTitle('请输入新名称')

        self.mainLayout=QVBoxLayout()

        self.originName_layout=QHBoxLayout()
        self.originName_label=QLabel('原名称:')
        self.originName=QLabel(originName)
        self.originName_blank=QLabel('    ')
        self.originName_layout.addWidget(self.originName_label)
        self.originName_layout.addWidget(self.originName)

        self.newName_layout=QHBoxLayout()
        self.newName_label=QLabel('新名称:')
        self.edit=QLineEdit()
        self.btn=QPushButton('更改')
        self.btn.clicked.connect(self.outNewName)
        self.newName_layout.addWidget(self.newName_label)
        self.newName_layout.addWidget(self.edit)
        self.newName_layout.addWidget(self.btn)


        self.mainLayout.addLayout(self.originName_layout)
        self.mainLayout.addLayout(self.newName_layout)

        self.setLayout(self.mainLayout)

        # self.newname=originName


    def outNewName(self):
        if self.edit.text():
            self.newName_Signal.emit(self.edit.text())
            self.close()
        else:
            QMessageBox.information(self,'提示','请输入新名称')






if __name__ == '__main__':
    app=QApplication(sys.argv)
    rename=Rename('斗罗大陆')
    rename.show()
    sys.exit(app.exec_())